package model.common.template;

import java.util.List;

import model.common.root.DirectedRelationship;
import model.common.root.Element;

/** A TemplateBinding is a relationship between a TemplateableElement and a template that specifies the substitutions of actual
ParameterableElements for the formal TemplateParameters of the template. A TemplateParameterSubstitution specifies the actual
parameter to be substituted for a formal TemplateParameter within the context of a TemplateBinding. If no actual parameter is
specified in this binding for a formal parameter, then the default ParameterableElement for that formal TemplateParameter (if
specified) is used.<p>

A bound element may have multiple bindings, possibly to the same template. In addition, the bound element may contain
elements other than the bindings. The details of how the expansions of multiple bindings, and any other Elements owned by the
bound element, are combined together to fully specify the bound element are specific to the subclasses of TemplateableElement.
The general principle is that one evaluates the bindings in isolation to produce intermediate results (one for each binding), which
are then merged to produce the final result. It is the way the merging is done that is specific to each kind of TemplateableElement.<p>

A TemplateableElement may contain both a TemplateSignature and TemplateBindings. Thus a TemplateableElement may be
both a template and a bound element.<p>

A conforming tool may require that all formal TemplateParameters must be bound as part of a TemplateBinding (complete
binding) or may allow just a subset of the formal TemplateParameters to be bound (partial binding). In the case of complete
binding, the bound element may have its own TemplateSignature, and the TemplateParameters from this can be provided as actual
parameters of the TemplateBinding. In the case of partial binding, the unbound formal TemplateParameters act as formal
TemplateParameters of the bound element, which is thus still a template.<p>

<b>NOTE</b>. A TemplateParameter with a default can never be unbound, as it has an implicit binding to the default , even if an explicit
TemplateParameterSubstitution is not given for it.*/
public class TemplateBinding extends DirectedRelationship {

	// Attributes
	private List<TemplateParameterSubstitution> parameterSubstitutions = null;
	
	private TemplateSignature signature;
	
	/** ATemplateBinding implies that the bound element has the same well-formedness constraints and semantics as if the contents of
the template owning the target TemplateSignature were copied into the bound element, substituting any ParameterableElements
exposed as formal TemplateParameters by the corresponding ParameterableElements specified as actual template parameters in
the TemplateBinding. However, a bound element does not explicitly contain the model Elements implied by expanding the
templates to which it binds. Nevertheless, it is possible to define an expanded bound element that results from actually applying
the TemplateParameterSubstitution for a bound element to the target templates. */
	private TemplateableElement boundElement;

	// Constructor
	public TemplateBinding(Element source, Element target) {
		super(source, target);
	}

}
